
import 'package:simple_app/common/message/mess.dart';

//chat 信息
class Relay extends Mess {
  final String receiver;
  final String sender;

  const Relay(dynamic data, {required this.receiver, required this.sender})
      : super(type: 'relay', data: data);

  factory Relay.fromJson(Map<String, dynamic> jsonobj) {
    if (jsonobj['type'] != 'relay') {
      throw 'Error relay Type';
    }
    var item = Relay(jsonobj['data'],
        receiver: jsonobj['receiver'], sender: jsonobj['sender']);
    return item;
  }
  
  @override
  Map toJson() {
    Map<String, dynamic> map = <String, dynamic>{};
    map['type'] = type;
    map['data'] = data;
    map['receiver'] = receiver;
    map['sender'] = sender;
    return map;
  }
}
